<template>
  <div class="case">
    <div class="case-login">
      <div class="img">
        <!-- <img src="@/assets/img/博客.jpg" alt=""> -->
      </div>
      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-form-item label="用户名" prop="username">
        <el-input v-model="ruleForm.username" prefix-icon='iconfont icon-yonghu'></el-input>
      </el-form-item>
            <el-form-item label="密码" prop="password">
        <el-input v-model="ruleForm.password" prefix-icon='iconfont icon-password' show-password></el-input>
      </el-form-item>
</el-form>
      <p class="btn">
        <el-button type="primary" @click="deng">登录</el-button>
        <el-button type="info">重置</el-button>
      </p>
    </div>
  </div>
</template>

<script>

// import {LoginApi} from '../../../http/api'
import {LoginApi} from '@/http/api'
export default {
  data() {
    return {
        ruleForm:{
            username:'',
            password:''
        },
        rules: {
          username: [
            { required: true, message: '请输入用户名', trigger: 'blur' },
            { min: 3, max: 6, message: '长度在 3 到 6 个字符', trigger: 'blur' }
          ],
          password: [
            { required: true, message: '请输入密码', trigger: 'blur' },
            { min: 3, max: 6, message: '长度在 3 到 6 个字符', trigger: 'blur' }
          ],
        }
    };
  },
  methods:{
      deng(){
          this.$refs.ruleForm.validate(valid=>{
              console.log('登录成功',valid);
              if(!valid) return

              console.log('开始调用登录接口');
              LoginApi(this.ruleForm).then(res=>{
                  console.log('登录成功的结果',res);
              })
          });
      }
  }
};
</script>

<style lang="scss" scoped>
.case {
  background: #2b4b6b;
  width: 100%;
  height: 100%;
  position: relative;
  .case-login {
    padding: 20px;
    width: 500px;
    height: 250px;
    background: white;
    border-radius: 5px 5px 5px 5px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
    text-align: center;
    .img{
      width: 100px;
      height: 100px;
      border-radius: 50%;
      background:url('../../assets/img/博客.jpg') no-repeat;
      // box-shadow: spread;
      
      background-size: 100%;
      margin-top: -70px;
      margin-left: 40%;
      margin-bottom: 20px;
      
    }
    
  }
  .btn{
      float: right;
      
  }
}
</style>
